package com.ruoyi.reservation.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.reservation.mapper.ReservationMapper;
import com.ruoyi.reservation.domain.Reservation;
import com.ruoyi.reservation.service.IReservationService;

/**
 * 场馆预约Service业务层处理
 * 
 * @author HuLongHui
 * @date 2023-02-18
 */
@Service
public class ReservationServiceImpl implements IReservationService 
{
    @Autowired
    private ReservationMapper reservationMapper;

    /**
     * 查询场馆预约
     * 
     * @param reservationId 场馆预约主键
     * @return 场馆预约
     */
    @Override
    public Reservation selectReservationByReservationId(Long reservationId)
    {
        return reservationMapper.selectReservationByReservationId(reservationId);
    }

    /**
     * 查询场馆预约列表
     * 
     * @param reservation 场馆预约
     * @return 场馆预约
     */
    @Override
    public List<Reservation> selectReservationList(Reservation reservation)
    {
        if (!"admin".equals(SecurityUtils.getUsername())){
            reservation.setCreateBy(SecurityUtils.getUsername());
        }
        return reservationMapper.selectReservationList(reservation);
    }

    /**
     * 新增场馆预约
     * 
     * @param reservation 场馆预约
     * @return 结果
     */
    @Override
    public int insertReservation(Reservation reservation)
    {
        reservation.setCreateTime(DateUtils.getNowDate());
        return reservationMapper.insertReservation(reservation);
    }

    /**
     * 修改场馆预约
     * 
     * @param reservation 场馆预约
     * @return 结果
     */
    @Override
    public int updateReservation(Reservation reservation)
    {
        reservation.setUpdateTime(DateUtils.getNowDate());
        return reservationMapper.updateReservation(reservation);
    }

    /**
     * 批量删除场馆预约
     * 
     * @param reservationIds 需要删除的场馆预约主键
     * @return 结果
     */
    @Override
    public int deleteReservationByReservationIds(Long[] reservationIds)
    {
        return reservationMapper.deleteReservationByReservationIds(reservationIds);
    }

    /**
     * 删除场馆预约信息
     * 
     * @param reservationId 场馆预约主键
     * @return 结果
     */
    @Override
    public int deleteReservationByReservationId(Long reservationId)
    {
        return reservationMapper.deleteReservationByReservationId(reservationId);
    }
}
